#include "ffmpeg.h"
#include <buola/io.h>

namespace buola { namespace media { namespace ffmpeg {

void print_codec_info(io::CTextWriter &pWriter,AVCodec *pCodec)
{
    pWriter << "Codec: " << pCodec->name << " (" << pCodec->long_name << ")\n";
    pWriter << "   decode: " << (bool)pCodec->decode << "\n";
    pWriter << "   encode: " << (bool)pCodec->encode2 << "\n";
    pWriter << "   id: " << (int)pCodec->id << "\n";
    pWriter << "   type: " << (int)pCodec->type << "\n";
    pWriter << "   address: " << (void*)pCodec << "\n";
}

void init_ffmpeg()
{
    static bool lInit=false;

    if(!lInit)
    {
        av_register_all();

        AVCodec *lCodec=nullptr;
        while((lCodec=av_codec_next(lCodec)))
        {
            print_codec_info(msg_info(),lCodec);
        }

        lInit=true;
    }
}
    
/*namespace ffmpeg*/ } /*namespace media*/ } /*namespace buola*/ }
